<?php

namespace app\server\notice\model;

use app\common\model\Config;
use app\server\notice\interfaces\MsgDriver;

/**
 * 注册验证码策略
 *
 * Class SmsLogin
 * @package app\server\notice\model
 */
class SmsSimple implements MsgDriver
{

    private $_templateCode;
    private $_signName;

    /**
     * SmsSimple constructor.
     * @param string $tem
     */
    public function __construct(string $tem)
    {
        $this->_templateCode = Config::get($tem, 'sms');
        $this->_signName = Config::get('sign_name', 'sms');
    }

    /**
     * 发送注册验证码
     *
     * @param array $params ['mobile' => 18108016186, 'params' => ['code' => 1234]]
     * @return boolean|string
     * @throws \AlibabaCloud\Client\Exception\ClientException
     */
    public function msgSend(array $params = [])
    {
        return (new Sms())->index($params['mobile'], $this->_signName, $this->_templateCode['tem'], $params['params']);
    }
}